﻿using IService;
using Microsoft.AspNetCore.SignalR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Service
{
    [Service]
    public class SignalRSystemService: ISignalRSystemService
    {
        private readonly IHubContext<SignalRService> _hubContext;
        public SignalRSystemService(IHubContext<SignalRService> hubContext)
        {
            _hubContext = hubContext;
        }

        /// <summary>
        /// 发送通知给客户端
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public async Task ReceiveMsg(string key, string value)
        {
            try
            {
                await _hubContext.Clients.All.SendAsync("ReceiveMsg", key, value);
            }
            catch (Exception ex)
            {
                 
            }

        }
    }
}
